<?php

namespace App\Models\video;

use Illuminate\Database\Eloquent\Model;

// 操作模式记录日志
class OperateModeModel extends Model
{
    protected $table = "up_operate_mode"; //表名
    const CREATED_AT = null;
    const UPDATED_AT = null;

    //添加
    public static function toAdd($data, $getId=false){
        if(!$data)
            return true;
        if ($getId) {
            return  self::query()->insertGetId($data);
        } else {
            return  self::query()->insert($data);
        }
    }

    //根据条件获取数量
    public static function getCount($filter){
        if(!empty($filter)){
            return self::query()->where($filter)->count();
        }else{
            return self::query()->count();
        }
    }

    //根据ID删除数据
    public static function del($filter){
        $result = self::query()->where($filter)->delete();
        return $result;
    }
}
